

<template>

</template>

<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'

const orders = ref([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(10)
const search = ref('')

const fetchOrders = async () => {
  const params = new URLSearchParams({
    page: page.value,
    size: pageSize.value,
    search: search.value
  })
  const res = await fetch(`/orders/?${params}`)
  const data = await res.json()
  if (res.ok && data.status === 200) {
    orders.value = data.data
    // 如果有分页，data.count
  } else {
    ElMessage.error(data.msg || '获取订单失败')
  }
}

onMounted(fetchOrders)
</script>